﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>Open Douban Config</title>
</head>
<body>
    <div id="DoubanProviderConfigPage" data-role="page" class="page type-interior pluginConfigurationPage" data-require="emby-input,emby-button,emby-select,emby-checkbox">
        <div data-role="content">
            <div class="content-primary">
                <form id="DoubanProviderConfigForm">
                    <div class="inputContainer">
                        <label class="inputeLabel inputLabelUnfocused" for="ApiBaseUri">Api</label>
                        <input id="ApiBaseUri" name="ApiBaseUri" type="text" is="emby-input" />
                        <div class="fieldDescription">The API prefix URI, for example: http://192.168.1.11:5000</div>
                    </div>
                    <div class="inputContainer">
                        <label class="inputeLabel inputLabelUnfocused" for="Pattern">Pattern</label>
                        <input id="Pattern" name="Pattern" type="text" is="emby-input" />
                        <div class="fieldDescription">A regular expression filtering media name, for example: The.Lion.King.2019.1080p.BluRay.x264-[YTS.LT].mp4 >> The Lion King 2019</div>
                    </div>
                    <div class="selectContainer">
                        <label class="selectLabel inputLabelUnfocused" for="PosterSize">Poster Size</label>
                        <select id="PosterSize" name="PosterSize" type="select" is="emby-select" >
                            <option value="s">Small</option>
                            <option value="m">Medium</option>
                            <option value="l">Large</option>
                        </select>
                    </div>
                    <div>
                        <button is="emby-button" type="submit" class="raised button-submit block emby-button">
                            <span>Save</span>
                        </button>
                    </div>
                </form>
            </div>
        </div>
        <script type="text/javascript">
            var DoubanProviderConfig = {
                pluginUniqueId: '7834517B-1A9A-4758-9DD3-73FE02C98AA3'
            };

            $('#DoubanProviderConfigPage').on('pageshow', function () {
                Dashboard.showLoadingMsg();
                ApiClient.getPluginConfiguration(DoubanProviderConfig.pluginUniqueId).then(function (config) {
                    $('#ApiBaseUri').val(config.ApiBaseUri).change();
                    $('#Pattern').val(config.Pattern).change();
                    $('#PosterSize').val(config.PosterSize).change();
                    Dashboard.hideLoadingMsg();
                });
            });

            $('#DoubanProviderConfigForm').on('submit', function () {
                Dashboard.showLoadingMsg();
                ApiClient.getPluginConfiguration(DoubanProviderConfig.pluginUniqueId).then(function (config) {
                    config.ApiBaseUri = $('#ApiBaseUri').val();
                    config.Pattern = $('#Pattern').val();
                    config.PosterSize = $('#PosterSize').val();
                    ApiClient.updatePluginConfiguration(DoubanProviderConfig.pluginUniqueId, config).then(function (result) {
                        Dashboard.processPluginConfigurationUpdateResult(result);
                    });
                });
                return false;
            });
        </script>
    </div>
</body>
</html>
